#pragma once
/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework Class Library
 * Version 2.00
 * 
 * Disposable Object Class
 *      Provides a base class for IDisposable Implementation.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
#include "stdafx.h"
using namespace System;

namespace Adaptive
{
	namespace Foundation
	{
		/// <summary>
		/// Provides a base class for the <see cref="IDisposable"/> Implementation.
		/// </summary>
		public ref class DisposableObjectBase abstract : public IDisposable
		{
		public:
			/*--------------------------------------------------------------------------------
			 * Public Event Definitions
			 *------------------------------------------------------------------------------*/
			#pragma region Public Event Definitions
			/// <summary>
			/// Occurs when the instance is disposed.
			/// </summary>
			event EventHandler^ Disposing;
			#pragma endregion

			/*--------------------------------------------------------------------------------
			 * Public Properties
			 *------------------------------------------------------------------------------*/
			#pragma region Public Properties
			/// <summary>
			/// Gets a value indicating whether the object has been disposed.
			/// </summary>
			/// <value>
			/// <b>true</b> if the <see cref="Dispose()"/> method has already been called on the
			/// instance; otherwise, <b>false</b>.
			/// </value>
			property bool Disposed { bool get(); }
			#pragma endregion
 
			/*--------------------------------------------------------------------------------
	         * Public Methods / Functions
		     *------------------------------------------------------------------------------*/
			#pragma region Public Methods / Functions
			/// <summary>
			/// Clears the contents of the object instance without disposing of the instance.
			/// </summary>
			!DisposableObjectBase();
	        #pragma endregion

		protected:
			/*--------------------------------------------------------------------------------
			 * Constructor / Dispose / Destructor Methods
			 *------------------------------------------------------------------------------*/
			#pragma region Constructor / Dispose / Destructor Methods
			/// <summary>
			/// Initializes a new instance of the class.
			/// </summary>
			/// <remarks>
			/// This is the default constructor.
			/// </remarks>
			DisposableObjectBase();
			/// <summary>
			/// Class destructor.
			/// </summary>
			~DisposableObjectBase();
			#pragma endregion

			/*--------------------------------------------------------------------------------
			 * Protected Methods / Event Methods
			 *------------------------------------------------------------------------------*/
			#pragma region Protected Methods / Event Methods
			/// <summary>
			/// Raises the <see cref="Disposing"/> event.
			/// </summary>
			/// <param name="e">
			/// An <see cref="EventArgs"/> event arguments instance.
			/// </param>
			virtual void OnDisposing(EventArgs^ e);
			#pragma endregion

		private:
			/*--------------------------------------------------------------------------------
			 * Private Member Declarations
			 *------------------------------------------------------------------------------*/
			#pragma region Private Member Declarations
			/// <summary>
			/// Disposed flag to prevent re-entrant calls.
			/// </summary>
			bool _disposed;
			#pragma endregion
		};
	}
}